package Servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Service.Servlet;
import vo.User;


@WebServlet("/modifypwd")
public class ModifypwdServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private Servlet a = new Servlet();
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		Integer id = Integer.parseInt(request.getParameter("id"));
		String pwd = request.getParameter("pwd");
		User us = a.findById(id); 
		us.setPassword(pwd);
		a.modifyPwd(us);
		request.getRequestDispatcher("index.jsp").forward(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {		
		doGet(request, response);
	}

}
